/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86155
 * date: 2024-04-02
 * Time: 11:07
 *
 * @author
 */

public class Test {
    public static void main(String[] args) {
        int sum = 0;
        System.out.println("1-50之间的素数:");
        for (int i = 1; i <= 50; i++) {
            for (int j = 2; j <= i; j++) {
                if(i%j == 0){
                    if(i == j){
                        sum += i;
                        System.out.print(" "+i);
                    }else{
                        break;
                    }
                }
            }
        }
        System.out.println();
        System.out.println("总数是:"+sum);
    }
    public static void main5(String[] args) {
        int sum = 0;
        for(int i = 1;i<=10;i++){
            sum+=i;
            if(sum>20){
                System.out.println("当前数是："+i);
                break;
            }
        }
    }
    public static void main4(String[] args) {
        int sum = 1;//第十天的桃数
        for (int i = 1; i < 10 ; i++) {
            sum = (sum +1)*2;//反推
        }
        System.out.println("桃树"+sum);
    }
    //水仙花数
    public static void main3(String[] args) {
        for (int i = 100; i < 999; i++) {
            int sum = 0;
            int j = i;
            while(j>0){
                sum += Math.pow(j%10,3);
                j /= 10;
            }
            if(i == sum){
                System.out.println(i);
            }
        }
    }
    public static void main2(String[] args) {
        int sum = 0;
        for (int i = 1; i <= 100 ; i++) {
            sum += i;
        }
        System.out.println(sum);
    }
    public static void main1(String[] args) {
        int i = 1;
        while(i <= 9){
            int j = 1;
            while(j <= i){
                System.out.print("*");
                j++;
            }
            System.out.println();
            i++;
        }
    }
}
